Vue.component("addForm", {
  template: `<el-dialog title="添加成员" :visible.sync="visibleDialog">
  <el-button type="primary" style="margin-bottom: 5px;" size="small">添加</el-button>
  <el-table :data="data" stripe border style="width: 100%" >
    <el-table-column align="center" width="40" type="index"></el-table-column>
    <el-table-column align="center" prop="a" label="页面流水号"></el-table-column>
    <el-table-column align="center" prop="a" label="页面名称"></el-table-column>
    <el-table-column align="center" prop="a" label="操作" width="180"></el-table-column>
  </el-table>
  <div slot="footer" class="dialog-footer">
      <el-button @click="$emit('update:visible',false)">取 消</el-button>
  </div></el-dialog>`,
  props: ["visible", "data"],
  data() {
    return {
      visibleDialog: false,
      addForm: {
        User_ID: "",
        User_Name: "",
        Enterprise_Info_SerialNumber: $.cookie("enterprise"),
      },
      addRules: {
        User_ID: [
          { required: true, message: "请输入钉钉用户ID", trigger: "blur" },
        ],
        User_Name: [
          { required: true, message: "请输入用户昵称", trigger: "blur" },
        ],
      },
      loading: false,
    };
  },
  watch: {
    visible() {
      this.visibleDialog = this.visible;
    },
    visibleDialog(val) {
      this.$emit("update:visible", val);
    },
  },
  methods: {},
});
new Vue({
  el: "#app",
  data() {
    return {
      form: {
        level: "",
        order: "",
        Model_Name: "",
        page: 1, //页数
        limit: 100, //每页数据条数
      },
      total: 0,
      tableData: [], //表格数据
      dialog: false,
      dialogData: [],
    };
  },
  mounted() {
    this.getList(this.form);
  },
  computed: {
    Level() {
      return function (level) {
        if (level == "1") {
          return "一级菜单";
        } else if (level == "2") {
          return "二级菜单";
        } else if (level == "3") {
          return "三级菜单";
        } else {
          return "";
        }
      };
    },
  },
  methods: {
    onSerach() {
      //查询方法
      this.form.page = 1;
      this.getList(this.form);
    },
    addContract() {
      window.location.href = "./Add.html";
    },
    handleSizeChange(val) {
      this.form.page = 1;
      this.form.limit = val;
      this.getList(this.form);
    },
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form);
    },
    getList(data) {
      //换页方法
      let _this = this;
      $.ajax({
        type: "POST",
        // url: `${DomainName}/getMenuAllAction?token=${$.cookie("token")}`,
        url: `https://service.kdddy.cn/donghuiwar/svysj/getMenuAllAction?token=`,
        data,
        // complete: function (XMLHttpRequest) {
        //   if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
        //     window.parent.document.location.href =
        //       "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
        //   }
        // },
        success: function (Result) {
          if (Result.Status == "success") {
            _this.tableData = Result.tableData;
            _this.total = parseInt(Result.limit);
          }
        },
        dataType: "json",
      });
    },
    handleConfig(Page_SerialNumber) {
      sessionStorage.setItem("Page_SerialNumber", Page_SerialNumber);
      window.location.href =
        "./Config.html?Page_SerialNumber=" + Page_SerialNumber;
    },
    editMember(Model_Number) {
      sessionStorage.setItem("Model_Number", Model_Number);
      window.location.href = "./Edit.html?Model_Number=" + Model_Number;
    },
    deletMember(Model_Number) {
      this.$confirm("警告！此操作将删除此菜单栏目, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.delete(Model_Number);
        })
        .catch(() => {
          this.$message({
            type: "warning",
            message: "已取消删除",
          });
        });
    },
    delete(Model_Number) {
      const _this = this;
      $.ajax({
        url: DomainName + "/DeleteAction?token=" + $.cookie("token"),
        type: "POST",
        data: {
          TableName: "system_model_list",
          Primary_Key: Model_Number,
          Primary_Key_Name: "Model_Number",
          Operation_Name: "删除菜单",
        },
        success: function (res) {
          if (res.Status == "success") {
            _this.getList(_this.form);
            _this.$message({
              type: "success",
              message: "删除成功!",
            });
          }
        },
        // complete: function (XMLHttpRequest) {
        //   if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
        //     window.parent.document.location.href =
        //       absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
        //   }
        // },
      });
    },
  },
});
